<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script language=javascript src="dialog.js"></script>

<script language="javascript">
document.write ("<link href='../language/" + AvailableLangs["Active"] + ".css' type='text/css' rel='stylesheet'>");
document.write ("<link href='dialog.css' type='text/css' rel='stylesheet'>");

var sAction = "INSERT";
var sTitle = lang["DlgComInsert"];

var oControl;
var oSeletion;
var sRangeType;

var sFromUrl = "http://";
var sAlt = "";
var sBorder = "0";
var sBorderColor = "";
var sFilter = "";
var sAlign = "";
var sWidth = "";
var sHeight = "";
var sVSpace = "";
var sHSpace = "";

var sSLTUrl = "";
var sCheckFlag = "file";

oSelection = dialogArguments.eWebEditor.document.selection.createRange();
sRangeType = dialogArguments.eWebEditor.document.selection.type;

if (sRangeType == "Control") {
	if (oSelection.item(0).tagName == "IMG"){
		sAction = "MODI";
		sTitle = lang["DlgComModify"];
		sCheckFlag = "url";
		oControl = oSelection.item(0);
		sFromUrl = oControl.getAttribute("src", 2);
		sAlt = oControl.alt;
		sBorder = oControl.border;
		sBorderColor = oControl.style.borderColor;
		sFilter = oControl.style.filter;
		sAlign = oControl.align;
		sWidth = oControl.width;
		sHeight = oControl.height;
		sVSpace = oControl.vspace;
		sHSpace = oControl.hspace;
	}
}


document.write("<title>" + lang["DlgImg"] + "(" + sTitle + ")</title>");
if(config.BaseHref!=""){
	document.write("<base href='" + document.location.protocol + "//" + document.location.host + config.BaseHref + "'>");
}


function InitDocument(){
	AvailableLangs.TranslatePage(document);

	SearchSelectValue(d_filter, sFilter);
	SearchSelectValue(d_align, sAlign.toLowerCase());

	d_fromurl.value = sFromUrl;
	d_alt.value = sAlt;
	d_border.value = sBorder;
	d_bordercolor.value = sBorderColor;
	s_bordercolor.style.backgroundColor = sBorderColor;
	d_width.value = sWidth;
	d_height.value = sHeight;
	d_vspace.value = sVSpace;
	d_hspace.value = sHSpace;

	adjustDialog();
}


function RadioClick(what){
	if (what=="url"){
		d_checkfromfile.checked=false;
		d_fromurl.disabled=false;
		if (config.AllowBrowse=="1"){
			d_browse.disabled=false;
		}
		d_checkfromurl.checked=true;
		d_file.myform.uploadfile.disabled=true;
	}else{
		d_checkfromurl.checked=false;
		d_file.myform.uploadfile.disabled=false;
		d_checkfromfile.checked=true;
		d_fromurl.disabled=true;
		if (config.AllowBrowse=="1"){
			d_browse.disabled=true;
		}
	}
}


function UploadLoaded(){
	RadioClick(sCheckFlag);
}


function UploadError(sErrDesc){
	AbleItems();
	RadioClick('file');
	divProcessing.style.display="none";
	try {
		BaseAlert(d_file.myform.uploadfile,eval(sErrDesc));
	}
	catch(e){}
}


function UploadSaved(sPathFileName, sPathFileName_s){
	d_fromurl.value = sPathFileName;
	sSLTUrl = sPathFileName_s;
	ReturnValue();
}


function ReturnValue(){
	sFromUrl = d_fromurl.value;
	sAlt = d_alt.value;
	sBorder = d_border.value;
	sBorderColor = d_bordercolor.value;
	sFilter = d_filter.options[d_filter.selectedIndex].value;
	sAlign = d_align.value;
	sWidth = d_width.value;
	sHeight = d_height.value;
	sVSpace = d_vspace.value;
	sHSpace = d_hspace.value;

	if (sAction == "MODI") {
		if (sSLTUrl){
			oControl.src = sSLTUrl;
		}else{
			oControl.src = sFromUrl;
		}
		oControl.alt = sAlt;
		oControl.border = sBorder;
		oControl.style.borderColor = sBorderColor;
		oControl.style.filter = sFilter;
		oControl.align = sAlign;
		oControl.width = sWidth;
		oControl.height = sHeight;
		oControl.style.width = sWidth;
		oControl.style.height = sHeight;
		oControl.vspace = sVSpace;
		oControl.hspace = sHSpace;
		if (sSLTUrl){
			oSelection.execCommand("CreateLink",false,sFromUrl);
			var oSel = oSelection(0).parentNode;
			oSel.target = "_blank";
		}
	}else{
		var sHTML = '';
		if (sFilter!=""){
			sHTML=sHTML+'filter:'+sFilter+';';
		}
		if (sBorderColor!=""){
			sHTML=sHTML+'border-color:'+sBorderColor+';';
		}
		if (sHTML!=""){
			sHTML=' style="'+sHTML+'"';
		}
		if (sSLTUrl){
			sHTML = '<img id=eWebEditor_TempElement_Img src="'+sSLTUrl+'"'+sHTML;
		}else{
			sHTML = '<img id=eWebEditor_TempElement_Img src="'+sFromUrl+'"'+sHTML;
		}
		if (sBorder!=""){
			sHTML=sHTML+' border="'+sBorder+'"';
		}
		if (sAlt!=""){
			sHTML=sHTML+' alt="'+sAlt+'"';
		}
		if (sAlign!=""){
			sHTML=sHTML+' align="'+sAlign+'"';
		}
		if (sWidth!=""){
			sHTML=sHTML+' width="'+sWidth+'"';
		}
		if (sHeight!=""){
			sHTML=sHTML+' height="'+sHeight+'"';
		}
		if (sVSpace!=""){
			sHTML=sHTML+' vspace="'+sVSpace+'"';
		}
		if (sHSpace!=""){
			sHTML=sHTML+' hspace="'+sHSpace+'"';
		}
		sHTML=sHTML+'>';
		if (sSLTUrl){
			sHTML = '<a href="'+sFromUrl+'" target="_blank">'+sHTML+'</a>';
		}
		dialogArguments.insertHTML(sHTML);

		var oTempElement = dialogArguments.eWebEditor.document.getElementById("eWebEditor_TempElement_Img");
		if (sSLTUrl){
			oTempElement.src = sSLTUrl;
		}else{
			oTempElement.src = sFromUrl;
		}
		oTempElement.removeAttribute("id");

	}

	window.returnValue = null;
	window.close();
}


function ok(){

	d_border.value = ToInt(d_border.value);
	d_width.value = ToInt(d_width.value);
	d_height.value = ToInt(d_height.value);
	d_vspace.value = ToInt(d_vspace.value);
	d_hspace.value = ToInt(d_hspace.value);

	if (!IsColor(d_bordercolor.value)){
		BaseAlert(d_bordercolor,lang["DlgImgErrBorColor"]);
		return false;
	}
	
	if (d_checkfromurl.checked){
		ReturnValue();
	}else{
		if (!d_file.CheckUploadForm()) return false;
		DisableItems();
		divProcessing.style.display="";
		d_file.myform.submit();
	}
}


function DisableItems(){
	d_checkfromfile.disabled=true;
	d_checkfromurl.disabled=true;
	d_fromurl.disabled=true;
	if (config.AllowBrowse=="1"){
		d_browse.disabled=true;
	}
	d_alt.disabled=true;
	d_border.disabled=true;
	d_bordercolor.disabled=true;
	d_filter.disabled=true;
	d_align.disabled=true;
	d_width.disabled=true;
	d_height.disabled=true;
	d_vspace.disabled=true;
	d_hspace.disabled=true;
	Ok.disabled=true;
}


function AbleItems(){
	d_checkfromfile.disabled=false;
	d_checkfromurl.disabled=false;
	d_fromurl.disabled=false;
	if (config.AllowBrowse=="1"){
		d_browse.disabled=false;
	}
	d_alt.disabled=false;
	d_border.disabled=false;
	d_bordercolor.disabled=false;
	d_filter.disabled=false;
	d_align.disabled=false;
	d_width.disabled=false;
	d_height.disabled=false;
	d_vspace.disabled=false;
	d_hspace.disabled=false;
	Ok.disabled=false;
}

function doPreview(){
	var url;
	if (d_checkfromurl.checked){
		url = d_fromurl.value;
	}else{
		url = d_file.document.myform.uploadfile.value;
	}
	if (url){
		imgPreview.src = url;		
		setPreview()
	}else{
		tdPreview.innerHTML = "";
	}

}

function setPreview(){
	var width = imgPreview.width;
	var height = imgPreview.height;
	if (imgPreview.src){
		var boxWidth = tdPreview.offsetWidth;
		var boxHeight = tdPreview.offsetHeight;
		if ((width>boxWidth)||(height>boxHeight)){
			var nw = boxWidth/width;
			var nh = boxHeight/height;
			if (nw>nh){
				height = boxHeight;
				width = width*nh;
			}else{
				width = boxWidth;
				height = height*nw;
			}
		}
		tdPreview.innerHTML = "<img border=0 src='"+imgPreview.src+"' width='"+width+"' height='"+height+"'>";
		tdPreviewSize.innerHTML = imgPreview.width+" * "+imgPreview.height;
	}
}

</script>
<BODY onload="InitDocument()">
	<table border=0 cellpadding=0 cellspacing=5 id=tabDialogSize>
		<tr>
			<td>


				<table border=0 cellpadding=0 cellspacing=5 align=center>
					<tr>
						<td width="60%">

							<table border=0 cellpadding=0 cellspacing=0 align=center
								width="100%">
								<tr>
									<td>
										<fieldset>
											<legend>
												<span lang=DlgImgSource></span>
											</legend>
											<table border=0 cellpadding=5 cellspacing=0 width="100%">
												<tr>
													<td>

														<table border=0 cellpadding=0 cellspacing=2 width="100%">
															<tr>
																<td noWrap width="20%"><input type=radio
																	id="d_checkfromfile" value="1"
																	onclick="RadioClick('file')"><label
																	for=d_checkfromfile><span lang=DlgFromFile></span></label>:</td>
																<td noWrap width="80%"><Script Language=JavaScript>
					document.write("<iframe id=d_file frameborder=0 src='../" + config.ServerExt + "/upload." + config.ServerExt + "?type=image&style=" + config.StyleName + "&language=" + AvailableLangs["Active"] + "' width='100%' height='22' scrolling=no></iframe>");
					</Script></td>
															</tr>
															<tr>
																<td noWrap width="20%"><input type=radio
																	id="d_checkfromurl" value="1"
																	onclick="RadioClick('url')"><label
																	for=d_checkfromurl><span lang=DlgFromUrl></span></label>:</td>
																<td noWrap width="80%"><script
																		language="javascript">
				if (config.AllowBrowse=="1"){
					document.write("<input type=text id='d_fromurl' style='width:191px' size=30 value=''><input style='width:63px;height:18px;margin-left:2px;padding-top:0px;' type=button id='d_browse' onclick=\"SelectBrowse('image','fromurl')\" lang=DlgBtnBrowse align=absmiddle>");
				} else {
					document.write("<input type=text id='d_fromurl' style='width:100%' size=30 value=''>");
				}
				</script></td>
															</tr>
														</table>

													</td>
												</tr>
											</table>
										</fieldset>
									</td>
								</tr>
								<tr>
									<td height=5></td>
								</tr>
								<tr>
									<td>
										<fieldset>
											<legend>
												<span lang=DlgImgEffect></span>
											</legend>
											<table border=0 cellpadding=5 cellspacing=0 width="100%">
												<tr>
													<td>

														<table border=0 cellpadding=0 cellspacing=2 width="100%">
															<tr>
																<td noWrap width="20%"><span lang=DlgImgAlt></span>:</td>
																<td noWrap width="80%" colspan=4><input type=text
																	id=d_alt size=10 value="" style="width: 100%"></td>
															</tr>
															<tr>
																<td noWrap width="20%"><span lang=DlgImgBorder></span>:</td>
																<td noWrap width="29%"><input style="width: 80px"
																	type=text id=d_border size=10 value=""
																	ONKEYPRESS="event.returnValue=IsDigit();"></td>
																<td width="2%">&nbsp;</td>
																<td noWrap width="20%"><span lang=DlgImgBorderColor></span>:</td>
																<td noWrap width="29%"><input style="width: 62px"
																	type=text id=d_bordercolor size=7 value=""><img
																	border=0 src="../sysimage/rect.gif" width=18
																	style="cursor: hand" id=s_bordercolor
																	onclick="SelectColor('bordercolor')" align=absmiddle></td>
															</tr>
															<tr>
																<td noWrap width="20%"><span lang=DlgImgSpecEffect></span>:</td>
																<td noWrap width="29%"><select id=d_filter size=1
																	style="width: 80px">
																		<option value='' selected lang=DlgComNone></option>
																		<option value='Alpha(Opacity=50)' lang=DlgImgAlpha1></option>
																		<option
																			value='Alpha(Opacity=0, FinishOpacity=100, Style=1, StartX=0, StartY=0, FinishX=100, FinishY=140)'
																			lang=DlgImgAlpha2></option>
																		<option
																			value='Alpha(Opacity=10, FinishOpacity=100, Style=2, StartX=30, StartY=30, FinishX=200, FinishY=200)'
																			lang=DlgImgAlpha3></option>
																		<option value='blur(add=1,direction=14,strength=15)'
																			lang=DlgImgBlur1></option>
																		<option
																			value='blur(add=true,direction=45,strength=30)'
																			lang=DlgImgBlur2></option>
																		<option
																			value='Wave(Add=0, Freq=60, LightStrength=1, Phase=0, Strength=3)'
																			lang=DlgImgWave></option>
																		<option value='gray' lang=DlgImgGray></option>
																		<option value='Chroma(Color=#FFFFFF)'
																			lang=DlgImgChroma></option>
																		<option
																			value='DropShadow(Color=#999999, OffX=7, OffY=4, Positive=1)'
																			lang=DlgImgDropShadow></option>
																		<option value='Shadow(Color=#999999, Direction=45)'
																			lang=DlgImgShadow></option>
																		<option value='Glow(Color=#ff9900, Strength=5)'
																			lang=DlgImgGlow></option>
																		<option value='flipv' lang=DlgImgFlipv></option>
																		<option value='fliph' lang=DlgImgFliph></option>
																		<option value='grays' lang=DlgImgGrays></option>
																		<option value='xray' lang=DlgImgXray></option>
																		<option value='invert' lang=DlgImgInvert></option>
																</select></td>
																<td width="2%">&nbsp;</td>
																<td noWrap width="20%"><span lang=DlgAlign></span>:</td>
																<td noWrap width="29%"><select id=d_align size=1
																	style="width: 80px">
																		<option value='' selected lang=DlgComDefault></option>
																		<option value='left' lang=DlgAlignLeft></option>
																		<option value='right' lang=DlgAlignRight></option>
																		<option value='top' lang=DlgAlignTop></option>
																		<option value='middle' lang=DlgAlignMiddle></option>
																		<option value='bottom' lang=DlgAlignBottom></option>
																		<option value='absmiddle' lang=DlgAlignAbsmiddle></option>
																		<option value='absbottom' lang=DlgAlignAbsbottom></option>
																		<option value='baseline' lang=DlgAlignBaseline></option>
																		<option value='texttop' lang=DlgAlignTexttop></option>
																</select></td>
															</tr>
															<tr>
																<td noWrap width="20%"><span lang=DlgImgWidth></span>:</td>
																<td noWrap width="29%"><input style="width: 80px"
																	type=text id=d_width size=10 value=""
																	ONKEYPRESS="event.returnValue=IsDigit();" maxlength=4></td>
																<td width="2%">&nbsp;</td>
																<td noWrap width="20%"><span lang=DlgImgHeight></span>:</td>
																<td noWrap width="29%"><input style="width: 80px"
																	type=text id=d_height size=10 value=""
																	ONKEYPRESS="event.returnValue=IsDigit();" maxlength=4></td>
															</tr>
															<tr>
																<td noWrap width="20%"><span lang=DlgImgVSpace></span>:</td>
																<td noWrap width="29%"><input style="width: 80px"
																	type=text id=d_vspace size=10 value=""
																	ONKEYPRESS="event.returnValue=IsDigit();" maxlength=2></td>
																<td width="2%">&nbsp;</td>
																<td noWrap width="20%"><span lang=DlgImgHSpace></span>:</td>
																<td noWrap width="29%"><input style="width: 80px"
																	type=text id=d_hspace size=10 value=""
																	ONKEYPRESS="event.returnValue=IsDigit();" maxlength=2></td>
															</tr>
														</table>

													</td>
												</tr>
											</table>
										</fieldset>
									</td>
								</tr>
							</table>


						</td>
						<td width="40%" height="100%">

							<fieldset style="height: 100%">
								<legend>
									<span lang=DlgImgPreview></span>
								</legend>
								<table border=0 cellpadding=0 cellspacing=5 width="200"
									height="200" valign=top>
									<tr>
										<td colspan=2 bgcolor=#FFFFFF align=center valign=middle
											id=tdPreview height="100%"></td>
									</tr>
									<tr>
										<td id=tdPreviewSize></td>
										<td align=right><input type=button id=btnPreivew
											onclick="doPreview()" lang=DlgImgPreview></td>
									</tr>
								</table>
							</fieldset>

						</td>
					</tr>
					<tr>
						<td noWrap align=right colspan=2><input type=submit value=''
							id=Ok onclick="ok()" lang=DlgBtnOK>&nbsp;&nbsp;<input
							type=button value='' onclick="window.close();" lang=DlgBtnCancel></td>
					</tr>
				</table>


			</td>
		</tr>
	</table>


	<div id=divProcessing
		style="width: 200px; height: 30px; position: absolute; left: 70px; top: 100px; display: none">
		<table border=0 cellpadding=0 cellspacing=1 bgcolor="#000000"
			width="100%" height="100%">
			<tr>
				<td bgcolor=#3A6EA5><marquee align="middle"
						behavior="alternate" scrollamount="5">
						<font color=#FFFFFF><span lang=DlgComUploading></span></font>
					</marquee></td>
			</tr>
		</table>
	</div>
	<img id=imgPreview src='' border=0 style="visibility: hidden"
		onload="setPreview()">

</body>
</html>